<?php
/**
 * this resource adds Digitalus specific logic to the db app resource
 *
 */
class Dig_Application_Resource_Db extends Zend_Application_Resource_Db
{
    /**
     * we are going to try and match the db location to a domain
     * if it doesnt exist the set the default
     *
     * @param array $params
     * @return unknown
     */
    public function setParams (array $params)
    {
        if (isset($params['dbname'])) {
            $domainPath = str_replace('?', $_SERVER['SERVER_NAME'], $params['dbname']);
            if (file_exists($domainPath)) {
                $params['dbname'] = $domainPath;
            } else {
                $params['dbname'] = str_replace('?', 'default', $params['dbname']);
            }
        }
        $this->_params = $params;
        return $this;
    }
}
?>